﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UtilLib
{
    /// <summary>
    /// 扩展
    /// </summary>
    public static partial class Util
    {
        /// <summary>
        /// count次乘multiple 上限max
        /// </summary>
        /// <param name="sor"></param>
        /// <param name="max"></param>
        /// <param name="multiple"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public static long PowV2(long sor, long max, long multiple, long count)
        {
            long v = sor;
            for (int i = 0; i < count; i++)
            {
                if (v >= max)
                {
                    break;
                }
                v *= multiple;
            }
            v = Math.Min(v, max);
            return v;
        }
        /// <summary>
        /// 向上取整
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int IntCeiling(this double v)
        {
            return (int)(Math.Ceiling(v));
        }
        /// <summary>
        /// 向上取整
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int IntCeiling(this float v)
        {
            return (int)(Math.Ceiling(v));
        }
        /// <summary>
        /// 向上取整
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static long LongCeiling(this double v)
        {
            return (long)(Math.Ceiling(v));
        }
        /// <summary>
        /// 向上取整
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static long LongCeiling(this float v)
        {
            return (long)(Math.Ceiling(v));
        }

        /// <summary>
        /// 向下取整
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int IntFloor(this double v)
        {
            return (int)(Math.Floor(v));
        }
        /// <summary>
        /// 向下取整
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int IntFloor(this float v)
        {
            return (int)(Math.Floor(v));
        }
        /// <summary>
        /// 向下取整
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static long LongFloor(this double v)
        {
            return (long)(Math.Floor(v));
        }
        /// <summary>
        /// 向下取整
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static long LongFloor(this float v)
        {
            return (long)(Math.Floor(v));
        }
    }
}
